<?php
/**
 * Created by 张彪.
 * User: 小马出行
 * Date: 2018/1/20
 * Time: 13:13
 */
namespace app\admin\model;
use think\Db;
use think\model;
class PayLogModel extends Model
{
    public function getLogInfo($map,$field='a.*',$flag=true,$page=1,$limit=10)
    {
        $config = config('inner_db');
        return $flag ? Db::table('xm_pay_log a')->join("order_common b",'a.common_id=b.common_id','LEFT')
            ->join("user c",'a.uid=c.uid','LEFT')
            ->join("driver d",'a.driver_id=d.driver_id','LEFT')
            ->join("car_info e",'a.car_id=e.car_id','LEFT')
            ->where($map)->field($field)->page($page,$limit)->order('log_id desc')->select()
            : Db::table('xm_pay_log a')->join($config['database'].".inter_order_common b",'a.common_id=b.id','LEFT')
                ->join($config['database'].".xm_user c",'a.uid=c.uid','LEFT')
                ->join($config['database'].".inter_driver d",'a.driver_id=d.id','LEFT')
                ->join($config['database'].".inter_car_list e",'a.car_id=e.id','LEFT')
                ->where($map)->field($field)->page($page,$limit)->order('log_id desc')->select();
    }


    public function searchLogInfo($map,$field='a.*',$flag=true)
    {
        $config = config('inner_db');
        return $flag ? Db::table('xm_pay_log a')->join("order_common b",'a.common_id=b.common_id','LEFT')
            ->join("user c",'a.uid=c.uid','LEFT')
            ->join(['xm_driver_base'=>'d'],'a.driver_id=d.driver_id','LEFT')
            ->join("car_info e",'a.car_id=e.car_id','LEFT')
            ->where($map)->field($field)->order('log_id desc')->find()
            : Db::table('xm_pay_log a')->join($config['database'].".inter_order_common b",'a.common_id=b.id','LEFT')
                ->join($config['database'].".xm_user c",'a.uid=c.uid','LEFT')
                ->join($config['database'].".xm_driver_base d",'a.driver_id=d.driver_id','LEFT')
                ->join($config['database'].".inter_car_list e",'a.car_id=e.id','LEFT')
                ->where($map)->field($field)->order('log_id desc')->find();
    }
}